package com.edu.study.base.tbVideoConfig.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.edu.study.base.tbVideoConfig.domain.TbVideoConfig;
import com.edu.study.base.tbVideoConfig.service.ITbVideoConfigService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 视频管理Controller
 * 
 * @author zw
 * @date 2022-03-21
 */
@RestController
@RequestMapping("/study/videoconfig")
public class TbVideoConfigController extends BaseController
{
    @Autowired
    private ITbVideoConfigService tbVideoConfigService;

    /**
     * 查询视频管理列表
     */
    @PreAuthorize("@ss.hasPermi('study:videoconfig:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbVideoConfig tbVideoConfig)
    {
        startPage();
        List<TbVideoConfig> list = tbVideoConfigService.selectTbVideoConfigList(tbVideoConfig);
        return getDataTable(list);
    }

    /**
     * 导出视频管理列表
     */
    @PreAuthorize("@ss.hasPermi('study:videoconfig:export')")
    @Log(title = "视频管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TbVideoConfig tbVideoConfig)
    {
        List<TbVideoConfig> list = tbVideoConfigService.selectTbVideoConfigList(tbVideoConfig);
        ExcelUtil<TbVideoConfig> util = new ExcelUtil<TbVideoConfig>(TbVideoConfig.class);
        return util.exportExcel(list, "videoconfig");
    }

    /**
     * 获取视频管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('study:videoconfig:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tbVideoConfigService.selectTbVideoConfigById(id));
    }

    /**
     * 新增视频管理
     */
    @PreAuthorize("@ss.hasPermi('study:videoconfig:add')")
    @Log(title = "视频管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbVideoConfig tbVideoConfig)
    {
        return toAjax(tbVideoConfigService.insertTbVideoConfig(tbVideoConfig));
    }

    /**
     * 修改视频管理
     */
    @PreAuthorize("@ss.hasPermi('study:videoconfig:edit')")
    @Log(title = "视频管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbVideoConfig tbVideoConfig)
    {
        return toAjax(tbVideoConfigService.updateTbVideoConfig(tbVideoConfig));
    }

    /**
     * 删除视频管理
     */
    @PreAuthorize("@ss.hasPermi('study:videoconfig:remove')")
    @Log(title = "视频管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tbVideoConfigService.deleteTbVideoConfigByIds(ids));
    }
}
